//Control de Banners de TownBug
var advertise = {
	contenedor:null,
	city:'',
	actual:0,
	maxn:0,
	bannerList: [],
	init: function(content,city){
		this.contenedor=content;
		this.city=city;
		// se hacela carga delos Baners
		new Ajax.Request('advertiseServer.php', { method: 'post',
					parameters: 'city='+this.city,
					asynchronous: true,
					onSuccess: function(response) {
						advertise.make(response.responseText);
					}
		});
	},
	show:function(){
		var w=this.bannerList[this.actual][0];
		var h=this.bannerList[this.actual][1];
		var img=this.bannerList[this.actual][2];
		var link=this.bannerList[this.actual][3];
		if(Prototype.Browser.IE){
			this.contenedor.innerHTML='<a href="'+link+'" target="_blank"><img src="'+img+'" width="'+w+'" height="'+h+'" border="0"></a>'; 
		}else{
			this.contenedor.innerHTML='<a href="'+link+'" target="_blank"><img style="display:none;" onload="this.show();" src="'+img+'" width="'+w+'" height="'+h+'" border="0"></a>'; 
		}
		this.actual++;
		if(this.actual>=this.maxn){ this.actual=0; }
		setTimeout('advertise.show()',5000);
	},
	make:function(str){
		var x=str.split('@||@');
		this.maxn=x.length;
		for(var i=0;i<x.length;i++)
		{
			var w = x[i].split('|x|');
			this.bannerList.push(w);
		}
		this.show();
	}
};

